## [1] "Run Completed at 2018-02-07 14:55:02"

Absence data

Models

Random Baseline

\[ Yobs_{i,j} \sim Bernoulli(N(0,1.68)) \]

Note that this is a random probability of interaction on a per observation basis. This is different than a random link model. If we are interested in a binary network, a random interaction probability model will lead to a link probability of 1-(1/2)^n in n sampling events.

## sink("models/SpeciesIdentity.jags")
## cat("
##     model {
##     
##     for (x in 1:Nobs){
## 
##     #observation
##     logit(s[x])<-alpha[Bird[x],Plant[x]]
##     Yobs[x] ~ dbern(s[x])
##     
##     }
##     
##     #Assess Model Fit - Predict remaining data
##     for(x in 1:Nnewdata){
##     
##       #Generate prediction
##       logit(snew[x])<-alpha[NewBird[x],NewPlant[x]]
##       Ynew_pred[x]~dbern(snew[x])
##     
##       #Assess fit, proportion of corrected predicted observations
##       Enew[x]<-abs(Ynew[x]-Ynew_pred[x])
## 
##     }
##     
##     #Priors
## 
##     #Species level priors
##     for (i in 1:Birds){
##       for (j in 1:Plants){
## 
##         #Intercept
##         #logit prior, then transform for plotting
##         alpha[i,j] ~ dnorm(0,0.386)
##       } 
##     }
## 
##     #derived posterior predictive error
##     fitnew<-sum(Enew[])
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 0
##    Unobserved stochastic nodes: 1955
##    Total graph size: 7448
## 
## Initializing model

Assess Convergence

Species Identity

\[ Yobs_{i,j} \sim Bernoulli(\lambda_{i,j}) \]

## sink("models/SpeciesIdentity.jags")
## cat("
##     model {
##     
##     for (x in 1:Nobs){
## 
##     #observation
##     logit(s[x])<-alpha[Bird[x],Plant[x]]
##     Yobs[x] ~ dbern(s[x])
##     
##     }
##     
##     #Assess Model Fit - Predict remaining data
##     for(x in 1:Nnewdata){
##     
##       #Generate prediction
##       logit(snew[x])<-alpha[NewBird[x],NewPlant[x]]
##       Ynew_pred[x]~dbern(snew[x])
##     
##       #Assess fit, proportion of corrected predicted observations
##       Enew[x]<-abs(Ynew[x]-Ynew_pred[x])
## 
##     }
##     
##     #Priors
## 
##     #Species level priors
##     for (i in 1:Birds){
##       for (j in 1:Plants){
## 
##         #Intercept
##         #logit prior, then transform for plotting
##         alpha[i,j] ~ dnorm(0,0.386)
##       } 
##     }
## 
##     #derived posterior predictive error
##     fitnew<-sum(Enew[])
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 830
##    Unobserved stochastic nodes: 1125
##    Total graph size: 7448
## 
## Initializing model

Assess Convergence

Detectability + Species Identity

Observation Model:

\[ Yobs_{i,j,k,d} \sim Binomial(N_{i,j,k},\omega_i) \]

Process Model:

\[ N_{i,j,k} \sim Binomial(\lambda_{i,j}) \] \[ Yobs_{i,j} \sim Bernoulli(\lambda_{i,j}) \]

## sink("models/SpeciesIdentity_Detect.jags")
## cat("
##     model {
##     
##     #True interaction probability for each bird, plant
##     for (i in 1:Birds){
##       for(j in 1:Plants){
##           logit(s[i,j])<-alpha[i,j]
##         }
##     }
## 
##     #Observation Model
##     for (x in 1:Nobs){
##       
##       #Detection Process
##       z[x] ~ dbern(detect[Bird[x]]) 
##       
##       #Observation
##       p[x]<-z[x] * s[Bird[x],Plant[x]]
##       Yobs[x] ~ dbern(p[x])
##     }
##     
##     #Assess Model Fit - Predict remaining data
## 
##     for(x in 1:Nnewdata){
##     
##       #Generate prediction
##       znew[x] ~ dbern(detect[NewBird[x]])
##       pnew[x] <- znew[x]*s[NewBird[x],NewPlant[x]]
##   
##       #Predicted observation
##       Ynew_pred[x]~dbern(pnew[x])
##       
##       #Assess fit, proportion of corrected predicted links
##       Enew[x]<-abs(Ynew[x]-Ynew_pred[x])
##     
##     }
##     
##     #Priors
##     #Observation model
##     #Detect priors, logit transformed - Following lunn 2012 p85
##     for(x in 1:Birds){
##       logit(detect[x])<-dcam[x]
##       dcam[x]~dnorm(omega_mu,omega_tau)
##     }
##     
##     #Process Model
##     #Species level priors
##     for (i in 1:Birds){
##       for (j in 1:Plants){
##         #Logit Intercept
##         alpha[i,j] ~ dnorm(0,0.386)
##       } 
##     }
##     
##     #OBSERVATION PRIOR
##     omega_mu ~ dnorm(0,0.386)
##     omega_tau ~ dunif(0,10)
##     
##     #derived posterior predictive error
##     fitnew<-sum(Enew[])
##     
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 830
##    Unobserved stochastic nodes: 2647
##    Total graph size: 10491
## 
## Initializing model

Assess Convergence

# Incorporating species occurrence

If species co-occurrence is a prerequisite for interaction, then the absence of interactions may stem either from a lack of detectability or species absence. We can jointly model the presence of species as a function of elevation and then existance of an interaction.

Species Identity

Observation Model:

\[ Yobs_{i,j,k,d} \sim Binomial(N_{i,j,k},\omega_i) \]

Process Model:

\[ N_{i,j,k} \sim Binomial(\lambda_{i,j}) \] \[ Yobs_{i,j} \sim Bernoulli(\lambda_{i,j}) \]

## sink("models/SpeciesIdentity_Detect_Elevation.jags")
## cat("
##     model {
##     
##     #Ecological Process Model
##     #True State for each bird, plant, camera
##     for (i in 1:Birds){
##       for(j in 1:Plants){
##         for(k in 1:Cameras){
##           
##           #Occurrence 
##           logit(psi[i,j,k])<-alpha_occ[i] + beta_occ[i] * elevation[k] + beta2_occ[i] * elevation[k]^2
##           occ[i,j,k] ~ dbern(psi[i,j,k])
## 
##           #Interaction
##           logit(s[i,j,k])<-alpha[i,j]
## 
##           #Conditional probability of interaction|occurrence
##           rho[i,j,k] <- s[i,j,k] * occ[i,j,k]
##         }
##       }
##     }
##     
##     #Observation Model
##     for (x in 1:Nobs){
##     
##     #Detection Process
##     z[x] ~ dbern(detect[Bird[x]]) 
##     
##     #Observation, conditional on detection and occurrence.
##     p[x]<-z[x] * rho[Bird[x],Plant[x],Camera[x]]
##     Yobs[x] ~ dbern(p[x])
##     
##     #Observed discrepancy
##     #E[x]<-abs(Yobs[x]- s[Bird[x],Plant[x],Camera[x]])
##     }
##     
##     #Assess Model Fit - Predict remaining data
##     
##     for(x in 1:Nnewdata){
##     
##     #Generate prediction
##     znew[x] ~ dbern(detect[NewBird[x]])
##     pnew[x] <- znew[x]*rho[NewBird[x],NewPlant[x],NewCamera[x]]
##     
##     #Predicted observation
##     Ynew_pred[x]~dbern(pnew[x])
##     
##     #Assess fit, proportion of corrected predicted links
##     Enew[x]<-abs(Ynew[x]-Ynew_pred[x])
##     
##     }
##     
##     #Priors
## 
##     #Occurrence model
##     for(x in 1:Birds){
##     alpha_occ[x] ~ dnorm(0,0.386)
##     beta_occ[x] ~ dnorm(0,0.386)
##     beta2_occ[x] ~ dnorm(0,0.386)
##     }
## 
##     #Observation model
##     #Detect priors, logit transformed - Following lunn 2012 p85
##     for(x in 1:Birds){
##     logit(detect[x])<-dcam[x]
##     dcam[x]~dnorm(omega_mu,omega_tau)
##     }
##     
##     #Process Model
##     for (i in 1:Birds){
##     for (j in 1:Plants){
##     #Intercept
##     #logit prior, then transform for plotting
##     alpha[i,j] ~ dnorm(0,0.386)
##     }
##     }
##     
##     #Observation group prior
##     omega_mu ~ dnorm(0,0.386)
##     omega_tau ~ dunif(0,10)
##     
##     #derived posterior predictive check
##     fitnew<-sum(Enew[])
##     
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 830
##    Unobserved stochastic nodes: 35542
##    Total graph size: 81903
## 
## Initializing model
## 
##    user  system elapsed 
##  13.165   0.099  13.418

Assess Convergence

Elevation ranges

Model Comparison

By Species

Detectability

Proportion of predicted observations

Predicted network statistics

Dashed line is the observed network from the time-series.

Comparing predictors

How much to do here.

Predicted betadiversity

Split data into wet (November - May) versus dry season (June - October)

Change in the probability of species interaction

## sink("models/SpeciesIdentity_Detect_Elevation_Beta.jags")
## cat("
##     model {
##     
##     #Ecological Process Model
##     #True State for each bird, plant, camera
##     for (i in 1:Birds){
##     for(j in 1:Plants){
##     for(k in 1:Cameras){
##     
##     #Occurrence 
##     logit(psi[i,j,k])<-alpha_occ[i] + beta_occ[i] * elevation[k] + beta2_occ[i] * elevation[k]^2
##     occ[i,j,k] ~ dbern(psi[i,j,k])
##     
##     #Interaction
##     logit(s[i,j,k])<-alpha[i,j] + beta_season[i,j] *Season[k]
##     
##     #Conditional probability of interaction|occurrence
##     rho[i,j,k] <- s[i,j,k] * occ[i,j,k]
##     }
##     }
##     }
##     
##     #Observation Model
##     for (x in 1:Nobs){
##     
##     #Detection Process
##     z[x] ~ dbern(detect[Bird[x]]) 
##     
##     #Observation, conditional on detection and occurrence.
##     p[x]<-z[x] * rho[Bird[x],Plant[x],Camera[x]]
##     Yobs[x] ~ dbern(p[x])
##     
##     #Observed discrepancy
##     #E[x]<-abs(Yobs[x]- s[Bird[x],Plant[x],Camera[x]])
##     }
##     
##     #Assess Model Fit - Predict remaining data
##     
##     for(x in 1:Nnewdata){
##     
##     #Generate prediction
##     znew[x] ~ dbern(detect[NewBird[x]])
##     pnew[x] <- znew[x]*rho[NewBird[x],NewPlant[x],NewCamera[x]]
##     
##     #Predicted observation
##     Ynew_pred[x]~dbern(pnew[x])
##     
##     #Assess fit, proportion of corrected predicted links
##     Enew[x]<-abs(Ynew[x]-Ynew_pred[x])
##     
##     }
##     
##     #Priors
##     
##     #Occurrence model
##     for(x in 1:Birds){
##     alpha_occ[x] ~ dnorm(0,0.386)
##     beta_occ[x] ~ dnorm(0,0.386)
##     beta2_occ[x] ~ dnorm(0,0.386)
##     }
##     
##     #Observation model
##     #Detect priors, logit transformed - Following lunn 2012 p85
##     for(x in 1:Birds){
##     logit(detect[x])<-dcam[x]
##     dcam[x]~dnorm(omega_mu,omega_tau)
##     }
##     
##     #Process Model
##     for (i in 1:Birds){
##     for (j in 1:Plants){
##         #Interaction probability
##         alpha[i,j] ~ dnorm(0,0.386)
##         #Effect of season
##         beta_season[i,j] ~ dnorm(0,0.386)
##     }
##     }
##     
##     #Observation group prior
##     omega_mu ~ dnorm(0,0.386)
##     omega_tau ~ dunif(0,10)
##     
##     #derived posterior predictive check
##     #fitnew<-sum(Enew[])
##     
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 830
##    Unobserved stochastic nodes: 35992
##    Total graph size: 84674
## 
## Initializing model
## 
##    user  system elapsed 
##  17.695   0.189  18.296

Effect of season on interaction probabilities

Dissimilairty in interactions (Beta_WN from Poisot 2012) Dashed line is the observed network from the time-series.

Note that this is really a measure of dissimilairty in one level (hummimngbirds), as the dissimilarity in plants is fixed by the sampling protocol. While there be a correlation between the species pool and the chosen plant to film, this is filtered by a human placing a camera at that plant, and as such isn’t a true measure of plant dissimiality.

Model overlap

Create a kind of venn diagram on PCA of model similarity based on per link discrepency.

## # A tibble: 22 x 3
## # Groups:   Model [4]
##    Model                      mean pair                                   
##    <chr>                     <dbl> <chr>                                  
##  1 Species                  -1.00  Collared Inca_Bomarea pardina          
##  2 Species_Detect           -1.00  Tawny-bellied Hermit_Fuchsia macrostig…
##  3 Species_Detect           -1.00  Tawny-bellied Hermit_Heliconia burleana
##  4 Species_Detect           -1.00  Violet-tailed Sylph_Palicourea acetoso…
##  5 Species_Detect           -0.950 Tawny-bellied Hermit_Centropogon solan…
##  6 Species_Detect           -0.950 Tawny-bellied Hermit_Columnea kucyniak…
##  7 Species_Detect           -0.950 Violet-tailed Sylph_Gasteranthus later…
##  8 Species_Detect           -0.950 Violet-tailed Sylph_Guzmania jaramilloi
##  9 Species_Detect           -0.950 Violet-tailed Sylph_Kohleria affinis   
## 10 Species_Detect_Elevation -0.950 Collared Inca_Bomarea pardina          
## # ... with 12 more rows

Without random model